<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="inc/taglibs.jsp" %>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <%@ include file="inc/meta.jsp" %>
    <meta name="description" content="">
    <meta name="author" content="">
    <title>帖子详情</title>
    <%@ include file="inc/css.jsp" %>
</head>
<body>

<div id="posts" class="wrapper">

    <%@ include file="inc/nav.jsp" %>

    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">帖子列表</h1>
                <h4 style="margin-left: 10px;">——帖子详情</h4>
            </div>
        </div>

        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <!-- /.panel-heading -->
                    <div class="panel-body">
                        <form class="form-horizontal">

                            <!-- 已经申请认证的帖子将展示认证信息 -->
                            <div class="form-group">
                                <label class="col-sm-2 control-label">发布者:</label>

                                <div class="col-sm-4" style="padding-top: 6.5px;">
                                    ${post.appUser.nickName}
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">内容:</label>

                                <div class="col-sm-8" style="padding-top: 6.5px;">
                                    ${post.content}
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">帖子图片:</label>

                                <div class="col-sm-9" style="padding-top: 6.5px;">
                                    <c:if test="${postImageList.size() == 0}">
                                        暂无
                                    </c:if>
                                    <c:forEach var="n" items="${postImageList}">
                                        <img src="${n.url}" height="200px" width="200px" style="margin: 3px;border: 1px solid #000000"/>
                                    </c:forEach>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">发布时间:</label>

                                <div class="col-sm-4" style="padding-top: 6.5px;">
                                    ${createTime}
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">审核状态:</label>

                                <div class="col-sm-4" style="padding-top: 6.5px;">
                                        <span id="showSpan">
                                            <c:if test="${post.checkStatus == 0}">待审核</c:if>
                                            <c:if test="${post.checkStatus == 1}">审核成功</c:if>
                                            <c:if test="${post.checkStatus == 2}">审核失败</c:if>
                                        </span>
                                </div>
                            </div>

                            <%--<c:if test="${post.checkStatus == 2}">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">审核失败原因:</label>

                                    <div class="col-sm-4" style="padding-top: 6.5px;">
                                            ${post.checkFailReason}
                                    </div>
                                </div>
                            </c:if>

                            <div class="form-group" style="display: none" id="hiddenDiv">
                                <label class="col-sm-2 control-label">审核失败原因:</label>

                                <div class="col-sm-4" style="padding-top: 6.5px;">
                                    <span id="tempSpan"></span>
                                </div>
                            </div>--%>

                            <div class="form-group">
                                <div class="col-sm-12" style="text-align: center">
                                    <c:if test="${post.checkStatus == 0}">
                                        <a href="javascript:void(0)" class="btn btn-success" id="checkButtonToSuccess" onclick="_postInfo.fn.changeStatus(${post.id},1)" role="button">审核成功</a>
                                        <a href="javascript:void(0)" class="btn btn-danger" id="checkButtonToFail" onclick="_postInfo.fn.changeStatus(${post.id},2)" role="button">审核失败</a>
                                    </c:if>
                                    <a href="backend/post/index" class="btn btn-primary" role="button">返回</a>
                                </div>
                            </div>
                        </form>
                    </div>
                    <!-- /.panel-body -->

                </div>
            </div>
        </div>

    </div>
    <!-- /#page-wrapper -->

</div>
<!-- /#wrapper -->

<div class="modal fade" id="checkModal" tabindex="-1" role="dialog" aria-labelledby="pwdModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">审核帖子</h4>
            </div>
            <div class="modal-body" id="showDivBody">
                确定将该帖子审核为成功？
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" onclick="_postInfo.fn.changeCheckStatus()" class="btn btn-primary">确定</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>

<div class="modal fade" id="delModal" tabindex="-1" role="dialog" aria-labelledby="pwdModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">审核失败原因</h4>
            </div>
            <div class="modal-body">
                <input type="hidden" id="postId" value="${post.id}"/>
                <textarea id="failReasonContent" cols="40" rows="6" class="form-control" style="resize: none;"></textarea>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" onclick="_postInfo.fn.changeCheckStatusToFail()" class="btn btn-primary">确定</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>

<%@ include file="inc/footer.jsp" %>

</body>

<script type="text/javascript">
    var _postInfo = {
        v: {
            id: "_postInfo",
            postId: 0,
            status: 0
        },
        fn: {
            changeStatus: function (id, status) {
                _postInfo.v.postId = id;
                _postInfo.v.status = status;
                if (status == 1) {
                    $('#showDivBody').html('确定将该帖子审核为成功？');
                } else {
                    $('#showDivBody').html('确定将该帖子审核为失败？');
                }
                $('#checkModal').modal("show");
            },
            changeCheckStatus: function () {
                $leoman.ajax("backend/post/changeCheckStatus", {
                    "postId": _postInfo.v.postId,
                    "status": _postInfo.v.status
                }, function (result) {
                    if (result == 1) {
                        $leoman.notify("操作成功", "success");
                        _postInfo.fn.endThings();
                        $('#checkModal').modal("hide");
                    } else {
                        $leoman.notify("操作失败", "error");
                    }
                });
            },
            endThings: function () {
                $('#checkButtonToSuccess').css("display", "none");
                $('#checkButtonToFail').css("display", "none");
                if (_postInfo.v.status == 2) {
                    // $('#tempSpan').html(content);
                    $('#showSpan').html('审核失败');
                    // $('#hiddenDiv').css('display', '');
                } else {
                    $('#showSpan').html('审核成功');
                }
            }
        }
    }
</script>

</html>